﻿using System;

using System.Collections.Generic;
using System.Text;
using NMock2;
using Xunit;
using DirectUI.Mobile.UI;
namespace DirectUIUnitTest
{
  public   class TimerTest
    {
      [Fact]
      public void TickEvent_Only_Fire_When_Enable_Is_True()
      {
          Timer timer = new Timer();
          int count = 0;
          timer.Interval = 20;
          timer.Tick += new EventHandler(
              delegate(object sender, EventArgs e)
              {
                  count++;
              }
      );
          timer.Enabled = true;
          System.Threading.Thread.Sleep(1000);
          Assert.True(count >=20);
          int count1 = count;
          timer.Enabled = false;
          System.Threading.Thread.Sleep(1000);

          Assert.True(count == count1);
      }
    }
}
